<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<!--Converted with LaTeX2HTML 98.1 release (February 19th, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->


<title>Cutting Sticks</title>
<meta name="description" content="Problem D: Cutting Sticks">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head><body bgcolor="#ffffff" lang="EN">

<h1><br clear="all"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">
Cutting Sticks</a>&nbsp;</font></b></td></tr></tbody></table></center>
</h1>
You have to cut a wood stick into pieces. The most affordable company, The
Analog Cutting Machinery, Inc. (ACM), charges money according to the length of
the stick being cut. Their procedure of work requires that they only make one
cut at a time. 

<p>
It is easy to notice that different selections in the order of
cutting can led to different prices. For example, consider a stick of length 10
meters that has to be cut at 2, 4 and 7 meters from one end. There are several
choices. One can be cutting first at 2, then at 4, then at 7. This leads to a
price of 10 + 8 + 6 = 24 because the first stick was of 10 meters, the
resulting of 8 and the last one of 6. Another choice could be cutting at 4,
then at 2, then at 7. This would lead to a price of 10 + 4 + 6 = 20, which is
a better price. 

</p><p>
Your boss trusts your computer abilities to find out the
minimum cost for cutting a given stick.

</p><p>

</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">
Input</a>&nbsp;</font>
</h2> 
The input will consist of several input cases. The first
line of each test case will contain a positive number <i>l</i> that represents the
length of the stick to be cut. You can assume <i>l</i> &lt; 1000. The next line will
contain the number <i>n</i> (<i>n</i> &lt; 50) of cuts to be made. 

<p>
The next line consists
of <i>n</i> positive numbers <i>c</i><sub><i>i</i></sub> (
<!-- MATH: $0 < c_i < l$ -->
0 &lt; <i>c</i><sub><i>i</i></sub> &lt; <i>l</i>) representing the places where the
cuts have to be done, given in strictly increasing order. 

</p><p>
An input case with <i>l</i> = 0 will represent the end of the input. 

</p><p>

</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">
Output</a>&nbsp;</font>
</h2> 
You have to print the cost of the
optimal solution of the cutting problem, that is the minimum cost of cutting
the given stick. Format the output as shown below. 

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">
Sample Input</a>&nbsp;</font>
</h2>
<pre>100
3
25 50 75
10
4
4 5 7 8
0
</pre>

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001004000000000000000">
Sample Output</a>&nbsp;</font>
</h2>
<pre>The minimum cutting is 200.
The minimum cutting is 22.
</pre>

<p>
<br></p><hr>
<address>
<i>Miguel Revilla</i>
<br><i>2000-08-21</i>
</address>
</body></html>